/**
 * Created with IntelliJ IDEA.
 * Description: 牛客网: BM88 判断是否为回文字符串
 * <a href="https://www.nowcoder.com/practice/e297fdd8e9f543059b0b5f05f3a7f3b2?tpId=295&tqId=1089616&ru=/exam/company&qru=/ta/format-top101/question-ranking&sourceUrl=%2Fexam%2Fcompany">...</a>
 * User: DELL
 * Date: 2023-07-05
 * Time: 22:23
 */
public class Solution {
    /**
     * 解题思路:
     * 分别从前面和后面依次遍历比对即可
     */
    public boolean judge (String str) {
        // 判空处理
        if (str == null || str.length() == 0) {
            return false;
        }
        int left = 0;
        int right = str.length()-1;
        while (left < right) {
            if (str.charAt(left) != str.charAt(right)) {
                return false;
            }
            left++;
            right--;
        }
        return true;
    }
}